package cn.bonoon.controllers.fmm;
//package cn.bonoon.controllers.account;
//
//import static org.springframework.web.bind.annotation.RequestMethod.GET;
//import static org.springframework.web.bind.annotation.RequestMethod.POST;
//
//import javax.servlet.http.HttpServletRequest;
//
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.stereotype.Controller;
//import org.springframework.web.bind.annotation.PathVariable;
//import org.springframework.web.bind.annotation.RequestMapping;
//import org.springframework.web.bind.annotation.RequestParam;
//import org.springframework.web.bind.annotation.ResponseBody;
//import org.springframework.web.servlet.ModelAndView;
//
//import cn.bonoon.core.plugins.AccountService;
//import cn.bonoon.core.plugins.GroupService;
//import cn.bonoon.core.plugins.RoleService;
//import cn.bonoon.entities.RoleEntity;
//import cn.bonoon.kernel.web.controllers.AbstractController;
//import cn.bonoon.kernel.web.models.DialogModel;
//import cn.bonoon.kernel.web.models.JsonResult;
//
//@Controller
//@RequestMapping("s/sys/role")
//public class RoleAssignController extends AbstractController{
//
//	@Autowired
//	private RoleService roleService;
//
//	@Autowired
//	private AccountService accountService;
//
//	@Autowired
//	private GroupService groupService;
//
//	@RequestMapping(value = "!{mid}/accounts.do", method = { POST, GET })
//	public ModelAndView accounts(HttpServletRequest request, 
//			@PathVariable("mid") String mid, 
//			@RequestParam("id") Long id, 
//			@RequestParam("gridid") String gridid) {
//
//		DialogModel model = new DialogModel(mid, request);
//		model.addForm(id);
//		model.addObject("gridid", gridid);
//		model.addObject("id", id);
//		try{
//			RoleEntity role = roleService.get(id);
//			model.addObject("name", role.getName());
//
//			//把用户组列出来，可以选择这个用户加入哪些组
//			model.addObject("groups", accountService.accounts(role));
//			
//		}catch (Exception e) {
//			log(e);
//		}
//		return model.execute("sys/account/role-accounts");
//	}
//
//	@RequestMapping(value = "!{mid}/groups.do", method = { POST, GET })
//	public ModelAndView groups(HttpServletRequest request, 
//			@PathVariable("mid") String mid, 
//			@RequestParam("id") Long id, 
//			@RequestParam("gridid") String gridid) {
//
//		DialogModel model = new DialogModel(mid, request);
//		model.addForm(id);
//		model.addObject("gridid", gridid);
//		model.addObject("id", id);
//		try{
//			RoleEntity role = roleService.get(id);
//			model.addObject("name", role.getName());
//
//			//把用户组列出来，可以选择这个用户加入哪些组
//			model.addObject("groups", groupService.groups(role));
//			
//		}catch (Exception e) {
//			log(e);
//		}
//		return model.execute("sys/account/role-groups");
//	}
//
//	@ResponseBody
//	@RequestMapping(value = "!{mid}/group!save.b", method = POST)
//	public final JsonResult saveGroup(
//			@RequestParam("id") final Long id, 
//			@RequestParam("ids") Long[] ids) {
//		try{
//			//Long[] roleIds = StringHelper.toLongArray(roles, ",");
//			groupService.saveRoleGroups(getUser(), id, ids);
//			return JsonResult.result();
//		}catch (Exception e) {
//			return JsonResult.error(e);
//		}
//	}
//
//}
